package com.example.demos.service.impl;

import com.example.demos.dto.MenuDTO;
import com.example.demos.dto.SubMenuDTO;
import com.example.demos.mapper.MenuMapper;
import com.example.demos.service.MenuService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.servlet.http.HttpSession;
import java.math.BigInteger;
import java.util.List;


@Service
public class MenuServiceImpl implements MenuService {

    @Autowired
    private MenuMapper menuMapper;

    @Override
    public List<MenuDTO> select(HttpSession session) {
        Integer empId = (Integer) session.getAttribute("empId");
        List<MenuDTO> select = menuMapper.select(empId);
        for (MenuDTO menuDTO : select) {
            List<SubMenuDTO> subMenuDTOS = menuMapper.selectSubMenu(menuDTO.getId(), empId);
            menuDTO.setList(subMenuDTOS);
        }
        return select;
    }

}
